{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "toc": "true"
   },
   "source": [
    "# Table of Contents\n",
    " <p>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "executing gpml startup script...\n"
     ]
    }
   ],
   "source": [
    "run('gpml-matlab-v4.0-2016-10-19/startup.m')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "nobsv=3000;\n",
    "X = randn(nobsv,2);\n",
    "Y = randn(nobsv);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "meanfunc = [];                    % empty: don't use a mean function\n",
    "covfunc = @covSEiso;              % Squared Exponental covariance function\n",
    "likfunc = @likGauss;              % Gaussian likelihood"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "hyp = struct('mean', [], 'cov', [0 0], 'lik', 0);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "gp(hyp, @infGaussLik, meanfunc, covfunc, likfunc, X, Y);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ans =\n",
      "\n",
      "    1.6520\n"
     ]
    }
   ],
   "source": [
    "f = @() gp(hyp, @infGaussLik, meanfunc, covfunc, likfunc, X, Y);;\n",
    "timeit(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ans =\n",
      "\n",
      "    1.6494\n"
     ]
    }
   ],
   "source": [
    "covfunc = @covRQiso;\n",
    "hyp = struct('mean', [], 'cov', [0 0 0], 'lik', 0);\n",
    "f = @() gp(hyp, @infGaussLik, meanfunc, covfunc, likfunc, X, Y);;\n",
    "timeit(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ans =\n",
      "\n",
      "    1.8531\n"
     ]
    }
   ],
   "source": [
    "covfunc = { 'covSum', { 'covSEiso', 'covRQiso' } };\n",
    "hyp = struct('mean', [], 'cov', [0 0 0 0 0], 'lik', 0);\n",
    "f = @() gp(hyp, @infGaussLik, meanfunc, covfunc, likfunc, X, Y);;\n",
    "timeit(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ans =\n",
      "\n",
      "    1.8410\n"
     ]
    }
   ],
   "source": [
    "covfunc = { 'covProd', { 'covSEiso', 'covRQiso' } };\n",
    "hyp = struct('mean', [], 'cov', [0 0 0 0 0], 'lik', 0);\n",
    "f = @() gp(hyp, @infGaussLik, meanfunc, covfunc, likfunc, X, Y);;\n",
    "timeit(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ans =\n",
      "\n",
      "    1.9211\n"
     ]
    }
   ],
   "source": [
    "covfunc = { 'covSum', { 'covSEiso', 'covSEiso', 'covRQiso' } };\n",
    "hyp = struct('mean', [], 'cov', [0 0 0 0 0 0 0], 'lik', 0);\n",
    "f = @() gp(hyp, @infGaussLik, meanfunc, covfunc, likfunc, X, Y);;\n",
    "timeit(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ans =\n",
      "\n",
      "    1.9627\n"
     ]
    }
   ],
   "source": [
    "covfunc = {'covProd', {\n",
    "                        { 'covSum', { 'covSEiso', 'covRQiso' } }, \n",
    "                        'covSEiso'}\n",
    "                       };\n",
    "hyp = struct('mean', [], 'cov', [0 0 0 0 0 0 0], 'lik', 0);\n",
    "f = @() gp(hyp, @infGaussLik, meanfunc, covfunc, likfunc, X, Y);;\n",
    "timeit(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ans =\n",
      "\n",
      "    1.7292\n"
     ]
    }
   ],
   "source": [
    "covfunc = {@covMask, {1,@covSEiso}};\n",
    "hyp = struct('mean', [], 'cov', [0 0], 'lik', 0);\n",
    "f = @() gp(hyp, @infGaussLik, meanfunc, covfunc, likfunc, X, Y);;\n",
    "timeit(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ans =\n",
      "\n",
      "    1.8513\n"
     ]
    }
   ],
   "source": [
    "covfunc = { @covSum, { \n",
    "    {@covMask, {1, @covSEiso}}, \n",
    "    {@covMask, {2, @covRQiso}} \n",
    "        } \n",
    "    };\n",
    "hyp = struct('mean', [], 'cov', [0 0 0 0 0], 'lik', 0);\n",
    "f = @() gp(hyp, @infGaussLik, meanfunc, covfunc, likfunc, X, Y);;\n",
    "timeit(f)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "MATLAB",
   "language": "matlab",
   "name": "matlab"
  },
  "language_info": {
   "codemirror_mode": "octave",
   "file_extension": ".m",
   "help_links": [
    {
     "text": "MetaKernel Magics",
     "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
    }
   ],
   "mimetype": "text/x-octave",
   "name": "matlab",
   "version": "0.11.0"
  },
  "nav_menu": {},
  "toc": {
   "navigate_menu": true,
   "number_sections": true,
   "sideBar": true,
   "threshold": 6,
   "toc_cell": true,
   "toc_section_display": "block",
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
